﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebEntities;
using Tools.com.Pager;
using WebsiteUI.Models;

namespace WebsiteUI.Controllers
{
    public class testController : Controller
    {
        //
        // GET: /test/

        public ActionResult Index(int? page)
        {
            WebsiteDbEntities ctx = new WebsiteDbEntities();
            var query = ctx.FW_MenuItem.OrderByDescending(c => c.ItemID);
          //  PagedList<FW_MenuItem> list = query.ToPagedList(page??0, 5);//查询全部，不建议这个重载。。
         PagedList<FW_MenuItem> list = query.ToPagedList(page ?? 0, 5, query.Count());//建议这个，查询相应数据出来之后再分页
            return View(list);
        }

    }
}
